<template>
  <view class="detail">
    <view class="title">{{ (tabIndex == 0) ? '任务消息' : '系统消息' }}</view>
    <view class="time">发布时间：{{ dataDetails.createTime }}</view>
    <p class="content">{{ dataDetails.content }}</p>
  </view>
</template>

<script>

import {getSysNotice} from "@/api/ec/work/notice/sysNotice"
import {getSysTaskNotice} from "@/api/ec/work/notice/sysTaskNotice"

export default {
  data() {
    return {
      // 0:任务消息 1:系统消息
      tabIndex: 0,
      // 消息信息
      dataDetails: {},
    }
  },
  onLoad(option) {
    this.tabIndex = option.tabIndex;
    this.dataDetails = JSON.parse(option.dataDetails);
    // uni.$emit('fresh', {})
  },
  created() {
    if (this.tabIndex == 0) {
      this.handleTaskDetails();
    } else {
      this.handleSysDetails();
    }
  },
  methods: {
    /** 任务消息详情 */
    handleTaskDetails() {
      const id = this.dataDetails.id;
      getSysTaskNotice(id).then(response => {
        this.form = response.data;
        this.open = true;
        if (this.dataDetails.readed != 1) {
          uni.$emit('refreshMessageIndex');
        }
      });
    },
    /** 系统消息详情 */
    handleSysDetails() {
      const id = this.dataDetails.id;
      getSysNotice(id).then(response => {
        this.form = response.data;
        this.open = true;
        if (this.dataDetails.readed != 1) {
          uni.$emit('refreshMessageIndex');
        }
      });
    },
  }
}
</script>

<style scoped lang="scss">
page {
  background: $uni-bg-color;
}

.detail {
  padding: 30rpx;
  text-align: center;
}

.title {
  font-weight: 550;
  font-size: 38rpx;
}

.time {
  font-size: 22rpx;
  color: #999999;
  margin: 20rpx 0;
}

.content {
  color: #555555;
  text-align: left;
  text-indent: 2em;
  font-size: 28rpx;
  line-height: 46rpx;
  word-break: normal;
  white-space: pre-warp;
  word-wrapL: break-word;
}
</style>
